<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * @author GCifuentes  - gabriel.cifuentes@outlook.com
 *
 */
class Common_controller extends CI_Controller {

	private $oCommonModel;
	private $oUtilitario;//		 
	private $oLogging;
	
	function __construct(){
		parent::__construct();
		$session = $this->load->library('valida_sesion');
		$this->load->model('customer_model');
		$this->load->library('form_validation');
		$this->load->library('common');
	    //$this->load->model('common_model');
		$this->oCommonModel =  new Common_model();
		//$this->oUtilitario = new ad_ctl_utilitario(); 
		//$this->oLogging =  new ad_utl_logging();
		
	}
    
	/**
	 * Retorna json de todos los servicios disponibles
	 * @return Array
	 */    
    
    public function getJsonServices(){
    	$aRetorno =  'bad';
    	$aRetorno = $this->oCommonModel->getAllServices();
        
        if($aRetorno)
            echo json_encode($aRetorno);
        else
            echo json_encode($aRetorno); 
    }
    
   	public function  getJsonCustomers($aData = null){
   		$aRetorno = Array();
        $sTerm=$this->input->get("term");
        $aRetorno = $this->oCommonModel->getAllCustomer($sTerm);
        echo json_encode($aRetorno);exit();
    }
    
    public function  getJsonCustomersByRut($aData = null){
    	$aRetorno = Array();
    	$sTerm=$this->input->get("term");
        $aRetorno = $this->oCommonModel->getCustomerByRut($sTerm);
      // $this->oUtilitario->dbug($aRetorno);
      //  $this->oLogging->lwrite('prueba del archivo log');
        echo json_encode($aRetorno);exit();
    }
    
    
    
    
}